/* 功能： 取得id为参数的DOM对象
*  @param o  HTML标签的id
*  @return 非空：获取成功；null：获取失败
*/
function $O(o){return document.getElementById(o);}
////////////////////////////////////
function getExterVar(svar)
{
	var stest = "";
	try{
	var stest = eval(svar);
	}
	catch(e)
	{
		return;
	}
	return stest;
}
function addPtag()
{
	var ptag = getExterVar('ptag');
	if (typeof ptag == "undefined")
	{
		if ($O("container"))
		{
			var ptag = $O("container").getAttribute("ptag");
		}
	}
	if (typeof ptag != "string" || ptag.length <= 0)
	{
		return false;
	}
	if ($O("container"))
	{
		var arr_a = $O("container").getElementsByTagName("A");
	}
	else
	{
		var arr_a = document.getElementsByTagName("A");
	}
	
	for (var iA = 0; iA < arr_a.length; iA++)
	{
		addPtagA(arr_a[iA], ptag);
	}
}

function addPtagA(obj_a, ptag)
{
	var sHref = obj_a.href;
	if (typeof sHref == "string" && sHref.length > 0)
	{
		var sPostFix = '';
		if (sHref.match(/#/))
		{
			sPostFix = sHref.replace(/.*#/, "#");
			sHref = sHref.replace(/#.*/, "");
		}
		if (sHref.match(/PTAG=[0-9\.]*/i))
		{
			sHref = sHref.replace(/PTAG=[0-9\.]*/i,"PTAG="+ptag)
		}
		else if (sHref.match(/\?.+/))
		{
			sHref+="&PTAG="+ptag;
		}
		else
		{
			sHref+="?PTAG="+ptag;
		}
		sHref += sPostFix;
		obj_a.href = sHref;
	}
}
//////////////////////////////
function addEventAct(dom_add, event_lisenter, func)
{
	if (dom_add.addEventListener)
	{
		dom_add.addEventListener (event_lisenter,func,false);
	}
	else if (dom_add.attachEvent)
	{
		dom_add.attachEvent("on"+event_lisenter,func);
	}
	else
	{
		dom_add["on"+event_lisenter] = func;
	}
}

function removeEventAct(dom_add, event_lisenter, func)
{
	if (dom_add.removeEventListener)
	{
		dom_add.removeEventListener (event_lisenter,func,false);
	}
	else if (dom_add.detachEvent)
	{
		dom_add.detachEvent("on"+event_lisenter,func);
	}
	else
	{
		dom_add["on"+event_lisenter] = null;
	}
}

function onCheckImgAct()
{
	if (g_timer_img_load)
	{
		return;
	}
	g_timer_img_load = setTimeout(checkImgAct, 200);
}

function isImgDisplay(obj_img)
{
	var obj_parent = obj_img.parentNode;
	while (obj_parent)
	{
		if (typeof obj_parent.style != "undefined" && (obj_parent.style.display == 'none'  || obj_parent.style.visibility == 'hidden'))
		{
			return false;
		}
		obj_parent = obj_parent.parentNode;
	}
	return true;
}

function isNeedShowImg(obj_img, bottom)
{
	if (!isImgDisplay(obj_img))
	{
		return false;
	}
	var eOffsetTop = obj_img.offsetTop; 
	while(obj_img = obj_img.offsetParent){//元素具有offsetParent
	   eOffsetTop += obj_img.offsetTop;
	}

	return eOffsetTop<=bottom;//元素绝对offsetTop小于可视区bottom时即可见
}

function showImgAct(obj_img)
{
	obj_img.src = getInitSrcAct(obj_img);
}

function getInitSrcAct(obj_img)
{
	if (obj_img && obj_img.getAttribute)
	{
		var init_src = obj_img.getAttribute("init_src");
		if (typeof init_src == "string" && init_src.match(/http/))
		{
			return init_src;
		}
	}
	return null;
}

function getSrcAct(obj_img)
{
	if (obj_img && obj_img.getAttribute)
	{
		var init_src = obj_img.getAttribute("src");
		if (typeof init_src == "string" && init_src.match(/http/))
		{
			return init_src;
		}
	}
	return null;
}

function addImgLisenterAct(dom_add)
{
	imgLoadLisenterAct();
	g_dom_add = dom_add;
	setTimeout(function(x){return function(){addImgLisenterAct2(x);}}(dom_add), 0);
}

function addImgLisenterAct2(dom_add)
{
	var arr_lisenter = new Array();
	if (dom_add.tagName == "IMG")
	{
		var init_src = getInitSrcAct(obj_img);
		if (init_src)
		{
			arr_lisenter.push(obj_img);
		}
	}
	else
	{
		var arr_img = dom_add.getElementsByTagName("IMG");
		for (var iImg = 0; iImg < arr_img.length; iImg++)
		{
			var obj_img = arr_img[iImg];
			var init_src = getInitSrcAct(obj_img);
			if (init_src != null)
			{
				arr_lisenter.push(obj_img);
			}
		}
	}
	if (arr_lisenter.length > 0)
	{
		g_arr_img_check[g_arr_img_check.length] = arr_lisenter;
	}
	onCheckImgAct();
	
}

g_bInit_load_act = false;
function imgLoadLisenterAct()
{
	if (g_bInit_load_act)
	{
		return;
	}
	g_timer_img_load = null;
	g_arr_img_check  = new Array();
	addEventAct(window, "scroll", onCheckImgAct);
	addEventAct(window, "resize", onCheckImgAct);
 	g_bInit_load_act = true;
}
//////////////////////////////
function getTmpId(obj_dom)
{
	return getTmpAtt(obj_dom, "tmp_id");
}

function getTmpAtt(obj_dom, sGet)
{
	var sAtt = obj_dom.getAttribute(sGet);
	if (typeof sAtt != "string" && typeof sAtt != "number")
	{
		return null;
	}
	return sAtt;
}

function getTmpIdStr(sHTML)
{
	var sAtt = sHTML.replace(/^.*tmp_id="([^"]*)".*$/, "$1");
	return sAtt;
}

var valReg = new RegExp('\\{[^}]*\\}');
var tagTmpReg = new RegExp('<[a-zA-Z]+(([a-zA-Z_]*="[^"]*")|([a-zA-Z_]*=\'[^\']*\')|([a-zA-Z_]*=[^<>\'" ]+)|[ ]+)*\\Wtmp_id="[^"]*"(([a-zA-Z_]*="[^"]*")|([a-zA-Z_]*=\'[^\']*\')|([a-zA-Z_]*=[^<>\'" ]+)|[ ]+)*>');

/* 功能： 获取带有tmp_id的html标签
*  @param sTmp  html代码字符串
*  @return obj_r：匹配结果与匹配结果在原字符串的起始位置
*/
function getTmpTag(sTmp)
{
	var obj_r = {};
	if (sTmp == "")
	{
		obj_r.start = -1;
		return obj_r;
	}
	var arr_t = tagTmpReg.exec(sTmp);
	if (arr_t == null)
	{
		obj_r.start = -1;
	}
	else
	{
		obj_r.start = arr_t.index;
		obj_r.text  = arr_t[0];
	}
	return obj_r;
}

/* 功能： 递归遍历DOM对象的子对象，获取DOM对象内，所有的带有tmp_id的子对象(模板)，并保存在参数数组中
*  @param obj_dom  包含tmp_id的DOM对象
*  @param arr_tmps 保存tmp_id的子对象的数组
*/
function getTmpChilds(obj_dom, arr_tmps)
{
	var tmp_id = getTmpId(obj_dom);//检测当前DOM对象是否有tmp_id属性
	if (tmp_id)
	{
		arr_tmps[tmp_id] = obj_dom;
	}
	var obj_child = obj_dom.firstChild;
	while (obj_child)
	{
		if (obj_child.nodeType == 1)
		{
			getTmpChilds(obj_child, arr_tmps)//递归调用，以获取所有带tmp_id的子对象
		}
		obj_child = obj_child.nextSibling;
	}
}

/* 功能： 模板解析函数。分析DOM对象结构，提取出 带有大括号结构 不带大括号结构 带有tmp_id 三种结构，同时生存一个和json数据对应的数据结构(树状层级结构)。
*  @param strTag  DOM对象之前的html字符串
*  @param obj_dom  需要解析的DOM对象
*  @return 带有模板结构信息的数组。
*/
function getTmpInfo(strTag, obj_dom)
{
	var arr_info = new Array();
	var s = '';
	var arr_tmps = new Array();
	getTmpChilds(obj_dom, arr_tmps);
	var sHTML = obj_dom.innerHTML;
	var bFirst = true;
	while (1)//遍历DOM对象
	{
		var s = '';
		var obj_r = getTmpTag(sHTML);//查找tmp_id
		var iTmpIndex = obj_r.start;
		if (obj_r.start < 0)//如果没有tmp_id
		{
			if (bFirst)
			{
				s = strTag+sHTML;
			}
			else
			{
				s = sHTML;
			}
			getSplitInfo(s, arr_info);//直接分割字符串
			break;
		}
		else//如果有tmp_id
		{
			var sTmp = sHTML.substr(0, iTmpIndex);//对在tmp_id元素之前字符串
			if (bFirst)
			{
				s = strTag+sTmp;
			}
			else
			{
				s = sTmp;
			}

			getSplitInfo(s, arr_info);//进行分割字符串
			var tmp_id = getTmpIdStr(obj_r.text);//
			var obj_tmp = arr_tmps[tmp_id];
			var iIndex = sHTML.indexOf(obj_tmp.innerHTML, obj_r.start + obj_r.text.length);
			sHTML = sHTML.substr(iIndex + arr_tmps[tmp_id].innerHTML.length);
			sHTML = sHTML.replace(/^[ \r\n]*<\/[^>]*>/, '');

			var obj = {"flag":2, "t":tmp_id, "a":getTmpInfo(obj_r.text, obj_tmp), "tag":obj_tmp.tagName};//把带有tmp_id的DOM结构单独作为一类，并且递归解析结构内部
			arr_info.push(obj);
		}
		bFirst = false;
		
	}
	return arr_info;
}

/* 功能： 字符串分割函数，将字符串分割为大括号里面的与大括号外面的两种形态，并按照顺序保存在数组中
*  @param s  需要分割的字符串
*  @param arr_info  保存分割结果的数组
*/
function getSplitInfo(s, arr_info)
{
	while (1)
	{
		var arr_t = valReg.exec(s);
		if (arr_t != null)
		{
			if (arr_t.index != 0)
			{
				var stt = s.substr(0, arr_t.index);
				var obj = {"flag":0, "t":stt};
				arr_info.push(obj);
			}
			var iLen = arr_t[0].length ;
			var stt = arr_t[0].substr(1, iLen - 2);
			var obj = {"flag":1, "t":stt};
			arr_info.push(obj);
			s = s.substr(arr_t.index + iLen);
		}
		else
		{
			var obj = {"flag":0, "t":s};
			arr_info.push(obj);
			break;
		}
	}
}

function replaceSome(sHTML)
{
	sHTML = sHTML.replace(/\b_(href|onclick|style|src|onmouseover|onmouseout|onfocus)\b/g, "$1");
	sHTML = sHTML.replace(/\bimg_src\b/g, "src");
	sHTML = sHTML.replace(/\btmp_(info|id|memo)[^"]*"[^"]*"/g, "");
	return sHTML;
}

/* 功能： 处理模板中需要进行处理的部分。比如说{__index==1?'':"on"__}这样的代码。
*  @param json_data  JSON数据对象
*  @param sFunc  需要处理的字符串
*  @param index  从外部传入的数据
*  @param itemNum  从外部传入的数据
*  @return 字符串，模板中代码的执行结果
*/
function evalFunction(json_data, sFunc, index,itemNum)
{
	sFunc = sFunc.replace(/^[ ]*__|__[ ]*$/g, '');
	sFunc = sFunc.replace(/&amp;/g, "&");
	sFunc = sFunc.replace(/&gt;/g, ">");
	sFunc = sFunc.replace(/&lt;/g, "<");
	sFunc = sFunc.replace(/&nbsp;/g, " ");
	sFunc = sFunc.replace(/&quot;/g, '"');
	index = index+1;
	eval("var index="+index);
	eval("var itemNum="+itemNum);
	try{
		with(json_data)
		{
			var s = eval(sFunc);
		}
	}
	catch(e)
	{
		return "";
	}
	return s;
}

/* 功能： 根据getTmpInfo()函数得出的模板结构数组，取出对应的JSON对象进行填充
*  @param json_data  JSON数据对象
*  @param arr_tmp  模板结构数组
*  @param index   模板中代码需要的数据
*  @param itemNum  模板中代码需要的数据
*  @return 字符串，填充得到的HTML代码
*/
function fillActData(json_data, arr_tmp, index,itemNum)
{
	if (typeof index != "number")
	{
		index = 0;
	}
	var sHTML = '';
	var iLen = arr_tmp.length;
	for (var i = 0; i<iLen; i++)//遍历模板结构数组
	{
		var sTemp = '';
		var obj_tmp = arr_tmp[i];
		if (obj_tmp.flag == 0)//不带有大括号结构的，直接加入到HTML字符串中
		{
			sTemp += obj_tmp.t;
		}
		else if (obj_tmp.flag == 1)//带有大括号结构，但又不需要循环的，从JSON对象中找到对应的数据进行填充
		{
			var sFillTag = obj_tmp.t;
			if (sFillTag.match(/^[ ]*__.*__[ ]*$/))//其中模板中有代码的，则需要执行代码
			{
				sTemp += evalFunction(json_data, sFillTag, index,itemNum);//加上代码执行的结果
			}
			else//模板中没有代码的，直接使用JSON数据对象中，对应的数据进行填充
			{
				sFillTag = sFillTag.replace(/:[^}]*/, '');
				if (typeof json_data[sFillTag] != "undefined")
				{
					sTemp += json_data[sFillTag];
				}
			}
		}
		else if (obj_tmp.flag == 2)//需要循环的模板
		{
			var sFillTag = obj_tmp.t;
			sFillTag = sFillTag.replace(/:[^}]*/, '');
			var child_json = json_data[sFillTag];
			if (typeof  child_json == "object")
			{
				var arr_child = obj_tmp.a;
				var iChildNum = child_json.length;
				for (var j = 0; j < iChildNum; j++)
				{
					var sTagEnd = "";
					if (obj_tmp.tag != "IMG" && obj_tmp.tag != "img")
					{
						sTagEnd = "</"+obj_tmp.tag+">";
					}
					sTemp += fillActData(child_json[j], arr_child, j, iChildNum)+sTagEnd;
				}
			}
		}
		sHTML += sTemp;
	}
	sHTML = replaceSome(sHTML);//进行替换。比如_src替换成为src
	return sHTML;
}

function idGetTjw(json_data, arr_tjw)
{
	for (var key in json_data)
	{
		var sType = typeof json_data[key];
		if ((sType == "number" || sType == "string") && key == "tjw_src")
		{
			arr_tjw.push(json_data[key]);
		}
		else if (sType == "object")
		{
			idGetTjw(json_data[key], arr_tjw)
		}
	}
}

function idReplaceTjw(json_data, sTjw, tjw_list)
{
	for (var key in json_data)
	{
		var sType = typeof json_data[key];
		if ((sType == "number" || sType == "string") && key == "tjw_src")
		{
			
			if (json_data[key] == sTjw)
			{
				json_data.good = tjw_list;
			}
		}
		else if (sType == "object")
		{
			idReplaceTjw(json_data[key], sTjw, tjw_list)
		}
	}
}

g_arr_id_tjw = {};
g_arr_tjw_id={};
g_arr_id_json = {};
function fillActId(id_dom, json_data)
{
	var arr_tjw = new Array();
	idGetTjw(json_data, arr_tjw);
	if (arr_tjw.length > 0)
	{
		g_arr_id_tjw[id_dom] = arr_tjw;
		for (var i = 0; i < arr_tjw.length; i++)
		{
			actLoadScript(arr_tjw[i], "gb2312");
			var obj_tjw = getDomainId(arr_tjw[i]);
			g_arr_tjw_id[obj_tjw.pageId+"_"+obj_tjw.domainId] = id_dom;
		}
		g_arr_id_json[id_dom] = json_data;
		return;
	}
	fillActId2(id_dom, json_data);
}
function fillActId2(id_dom, json_data)
{
	var obj_dom  = $O(id_dom);
	if (!obj_dom)
	{
		return;
	}
	if (typeof json_data["attr"] != "undefined")
	{
		var attr = json_data["attr"];
		for (var key in attr)
		{
			var sType = typeof attr[key];
			if (sType == "number" || sType == "string")
			{
				if (key.match(/^bgImg$/i) && attr[key].match(/http/))
				{
					obj_dom.style.backgroundImage = "url("+attr[key]+")";
				}
				else if (key == "_href" && attr[key].match(/http/))
				{
					obj_dom.href = attr[key];
				}
				else if (key == "tjw_src" && attr[key].match(/http.*\.js/))
				{
					$O(id_dom).setAttribute("tjw_src", attr[key]);
					addTjwAct(id_dom, attr[key]);
				}
				else
				{
					obj_dom.setAttribute(key, attr[key]);
					var sGlobal = 'g_tmp_'+key+'="'+attr[key]+'"';
					eval(sGlobal);
				}
			}
		}
	}
	if (needFill(json_data))
	{
		if (!needFillTmp(json_data))
		{
			fillReplace($O(id_dom), json_data)
		}
		else
		{
			var arr_tmp = getTmpInfo("", $O(id_dom));
			obj_dom.innerHTML = fillActData(json_data, arr_tmp);
		}
	}
	addImgLisenterAct(obj_dom);
}

g_arr_tjw = new Array();
function addTjwAct(id, tjw_src)
{
	g_arr_tjw.push({"id":id, "tjw_src":tjw_src});
}

function loadTjw()
{
	var iLen = g_arr_tjw.length;
	for (var i = 0; i < iLen; i++)
	{
		var tjw_obj = g_arr_tjw[i];
		actLoadScript(tjw_obj.tjw_src, "gb2312");
	}
}

function getDomainId(sSrc)
{
	if (sSrc.length == 0)
	{
		return null;
	}
	var arr_id = sSrc.match(/^.*\/tjw([0-9]+)\/tjw[^\/]*\/tjw([0-9]+)\.js.*$/);
	if (arr_id && arr_id.length == 3)
	{
		return {pageId:parseInt(arr_id[1], 10), domainId:parseInt(arr_id[2], 10)};
	}
	return null;
}

function onLoadTjw(pageId, domainId, tjw_info)
{
	var id = g_arr_tjw_id[pageId+"_"+domainId];
	if (typeof id != "string")
	{
		return;
	}
	var arr_tjw = g_arr_id_tjw[id];
	
	var iLoad = 0;
	for (var j = 0; j < arr_tjw.length; j++)
	{
		if (!arr_tjw[j])
		{
			iLoad++;
			continue;
		}
		var obj_domain = getDomainId(arr_tjw[j]);
		
		if (obj_domain.pageId == pageId && obj_domain.domainId == domainId)
		{
			
			tjw_info.list.length = tjw_info.curCount;
			var tjwrd1 = ""+pageId+"."+domainId+".";
			for (var i = 0; i < tjw_info.list.length; i++)
			{
				var tjwrd = tjwrd1+(i+1);
				tjw_info.list[i].tjwrd=tjwrd;
			}

			idReplaceTjw(g_arr_id_json[id],arr_tjw[j],tjw_info.list);
			arr_tjw[j] = null;
			iLoad++;
			continue;
		}
		
	}
	
	if (iLoad >= arr_tjw.length)
	{
		if (typeof localFillActTjwId == "function")
		{
			bLocalFill = localFillActTjwId(id, g_arr_id_json[id]);
		}
		if (!bLocalFill)
		{
			fillActId2(id, g_arr_id_json[id]);
		}
		g_arr_id_json[id] = null;
		return true;
	}
	return false;
}

function commentListCallBack(obj_info, pageId, domainId)
{
	onLoadTjw(pageId, domainId, obj_info);
}

function fillReplace(obj_dom, json_data)
{
	var sHTML = obj_dom.innerHTML;
	sHTML = sHTML.replace(/%7b(.*)?%7d/ig, '{$1}');
	sHTML = sHTML.replace(new RegExp("\\{__(.*?)__\\}", "ig"), 
		(function(x){return function(a1, a2){return evalFunction(x, a2);}})(json_data));

	sHTML = sHTML.replace(/\{([^{}]*?):[^{}]*?\}/g, '{$1}');
	for (var key in json_data)
	{
		var sType = typeof json_data[key];
		if (sType == "number" || sType == "string")
		{
			sHTML = sHTML.replace(new RegExp("\\{"+key+"\\}", "ig"), json_data[key]);	
		}
	}
	sHTML = replaceSome(sHTML);
	obj_dom.innerHTML = sHTML;
}

function needFill(j)
{
	for (var key in j)
	{
		var sType = typeof j[key];
		if (key != "attr" && (sType == "object" || sType == "number" || sType == "string"))
		{
			return true;
		}
	}
	return false;
}

function needFillTmp(json_data)
{
	for (var key in json_data)
	{
		if (key != "attr" && typeof json_data[key] == "object")
		{
			return true;
		}
	}
	return false;
}

///////////////////////////////////////////
function getActName()
{
	var sUrl = window.location.href;
	sUrl = sUrl.replace(/index\.html.*$/, '');
	sUrl = sUrl.replace(/\?.*/, '');
	sUrl = sUrl.replace(/#.*/, '');
	sUrl = sUrl.replace(/\/$/, '');
	sUrl = sUrl.replace(/\.[^\/]*$/, '');
	sUrl = sUrl.replace(/^.*\//, '');
	return sUrl;
}

function actLoadScript(url, charset)
{
	var loader = new QZFL.JsLoader();
	loader.load(url, document, charset);
}

function getDataPath(sFrom)
{
	var sUrl = window.location.href;
	var sPath = sUrl.replace(/\?.*$/, '');
	sPath = sPath.replace(/#.*/, '');
	if (!sPath.match(/\.htm/))
	{
		if (sPath.match(/\/$/))
		{
			sPath += "index.html";
		}
		else
		{
			sPath += "/index.html";
		}
	}

	var sBase = '';
	if ('shop' == sFrom) {
		sBase = 'http://shop.qq.com/act/static/';
	} else if ('new' == 'sFrom') {
		sBase = 'http://imgcache.qq.com/qqshop/act/json/';
	} else {
		sBase = 'http://imgcache.qq.com/vipstyle/vipshop_v1/js_shopact/json/';
	}
	sPath = sPath.replace(/^.*qq\.com\//, sBase);
	if (sUrl.match(/[?&]s=/))
	{
		var peroid = sUrl.replace(/^.*[?&]s=([a-z0-9_]+).*$/, "$1");
		var sJson = sPath.replace(/\.htm.*$/, '/');
		sJson += peroid+".js";
	}
	else
	{
		var sJson = sPath.replace(/\.htm.*$/, '.js');
	}
	return sJson;
}

function getDataAct(sFrom)
{
	sFrom = sFrom || '';
	var sScript = getDataPath(sFrom);
	actLoadScript(sScript, 'utf-8');
}
//////////////////////////////////////////
function checkImgAct()
{
	g_timer_img_load = null;
	var scrollTop = document.documentElement.scrollTop ||document.body.scrollTop;
	if (document.documentElement.clientHeight)
	{
		var bottom = scrollTop + document.documentElement.clientHeight;
	}
	else
	{
		var bottom = scrollTop + document.body.clientHeight;
	}
	
	for (var iArr = 0; iArr < g_arr_img_check.length; iArr++)
	{
		if (!g_arr_img_check[iArr])
		{
			continue;
		}
		var arr_img = g_arr_img_check[iArr];
		var iHasShow = 0;
		for (var iImg = 0; iImg < arr_img.length; iImg++)
		{
			var obj_img = arr_img[iImg];
			if (!obj_img)
			{
				continue;
			}
			try{
			var bNeedShow = isNeedShowImg(obj_img, bottom);
			}
			catch(e)
			{
				var bNeedShow = false;
				arr_img[iImg] = null;
			}
			if (bNeedShow)
			{
				showImgAct(obj_img);
				arr_img[iImg] = null;
			}
			var src = getSrcAct(obj_img);
			if (src)
			{
				iHasShow++;
			}
		}
		if (iHasShow == arr_img.length)
		{
			g_arr_img_check[iArr] = null;
		}
	}
}

//函数接口
var g_arr_json_act_data = {};
/* 功能： 模板填充的接口函数，将参数指定的json数据填充到HTML模板中
*  @param json_data  json对象，里面包含了填充到HTML模板的数据
*  @param data_name  字符串，用来区分不同的json(一个模板有可能多次填充)
*  @return true：填充成功；false：填充失败
*/
function fillAct(json_data, data_name)
{
	if (typeof data_name == "string" || typeof data_name == "number")//此段暂时无用处
	{
		g_arr_json_act_data[data_name] = json_data;
	}
	if (typeof localFillAct == "function")//如果定义了本地定制的填充函数，则可以调用此函数对json进行处理
	{
		var bFilled = localFillAct(json_data, data_name);
		if (bFilled)
		{
			return true;
		}
	}
	for (var key in json_data)//每个key是和HTML DOM对象的id匹配的。
	{
		var sType = typeof json_data[key];
		if (sType == "object" || sType == "number" || sType == "string")
		{
			var bLocalFill = false;
			if (typeof localFillActId == "function")
			{
				bLocalFill = localFillActId(key, json_data[key]);
			}
			if (!bLocalFill)//对HTML模板进行填充
			{
				fillActId(key, json_data[key]);
			}
			if (typeof localAfterFillId == "function")
			{
				localAfterFillId(key, json_data[key]);
			}
		}
	}
	if (typeof localAfterFill == "function")//填充后续处理。比如说_src换成src。
	{
		setTimeout(function(x,y){return function(){localAfterFill(x,y)}}(json_data, data_name), 0);
	}
	if (g_arr_tjw.length > 0)//载入推荐位
	{
		setTimeout(loadTjw, 0);
	}
	setTimeout(addPtag, 0);//加上ptag
	return true;
}

function addTopButton(obj_btn, iBottom)
{
	if (!navigator.userAgent.match(/MSIE/))
	{
		obj_btn.style.position = 'fixed';
		obj_btn.style.bottom = iBottom+"px";
		return;
	}
	obj_btn.style.position = 'absolute';
	var autoMoveBtn = function(obj_btn, iBottom)
	{
		var scrollTop = document.documentElement.scrollTop ||document.body.scrollTop;
		if (document.documentElement.clientHeight)
		{
			var bottom = scrollTop + document.documentElement.clientHeight - iBottom - obj_btn.offsetHeight;
		}
		else
		{
			var bottom = scrollTop + document.body.clientHeight - iBottom - obj_btn.offsetHeight;
		}
		obj_btn.style.top = bottom+"px";
	};
	addEventAct(window, "scroll", function(){autoMoveBtn(obj_btn, iBottom);});
	addEventAct(window, "resize", function(){autoMoveBtn(obj_btn, iBottom);});
}

function get2Num(i)
{
	if (i < 10)
	{
		return "0"+i;
	}
	return ""+i;
}

function mkTime2(iTime)
{
	var t = new Date();
	t.setTime(iTime);
	return ''+t.getFullYear()+"-"+get2Num(t.getMonth()+1)+"-"+get2Num(t.getDate())+" "+get2Num(t.getHours())+":"+get2Num(t.getMinutes())+":"+get2Num(t.getSeconds());
}

function mkTime(year, month, day, hour, minute, second)
{
	var t = new Date();
	t.setDate(1);
	t.setFullYear(year);
	t.setMonth(month - 1);
	t.setDate(day);
	t.setHours(hour);
	t.setMinutes(minute);
	t.setSeconds(second);
	return Math.floor(t.getTime()/1000);
}

function mkTime3(start_time)
{
	var sTime = start_time;
	var arr_match = start_time.match(/([0-9]{1,4}.?)/g);
	for (var i = arr_match.length; i< 6;i++)
	{
		sTime += " 00";
	}
	sTime = sTime.replace(/[^0-9]{2,}/, " ");
	var arr_match = sTime.match(/([0-9]{4}).([0-9]{1,2}).([0-9]{1,2}).([0-9]{1,2}).([0-9]{1,2}).([0-9]{1,2})/);
	for (var i = 4; i <= 6; i++)
	{
		if (typeof arr_match[i] == "undefined")
		{
			arr_match[i] = "00";
		}
	}
	the_start = mkTime(arr_match[1], arr_match[2], arr_match[3], arr_match[4], arr_match[5], arr_match[6]);
	return the_start;
}

function notice_me(title, content, ntime)
{
	var isIE = navigator.userAgent.match(/MSIE/);
	if (isIE)
	{
		try{
			var xmlhttp=new ActiveXObject("TimwpDll.TimwpCheck");
			var  n = xmlhttp.GetHummerQQVersion();
			if (n < 2509)
			{
				if (confirm("您当前未安装QQ或使用的QQ版本过低，不支持此功能。请先下载QQ2009正式版SP4及以上版本。"))
				{
					window.target="_top";
					window.open("http://im.qq.com/");
				}
			}
			else
			{
				var cpAdder = new ActiveXObject("QQCPHelper.CPAdder");
				var retVal = cpAdder.AddMemoNote(title, content, 2, 0, ntime, 0);
			}
		}catch (e){
			if (confirm("您当前未安装QQ或使用的QQ版本过低，不支持此功能。请先下载QQ2009正式版SP4及以上版本。")){
				window.target="_top";
				window.open("http://im.qq.com/");
			}
		}
	}
	else
	{
		alert('对不起，只有IE浏览器才能使用此功能');
	}
	return false;
}

function select_addOption(objSelectNow,txt,val){var objOption = parent.document.createElement("OPTION");objOption.text= txt;objOption.value=val;objSelectNow.options.add(objOption);}
function getNavieUrl(sUrl)
{
	var sPath = sUrl.replace(/\?.*$/, '');
	sPath = sPath.replace(/#.*/, '');
	if (!sPath.match(/\.htm/))
	{
		if (sPath.match(/\/$/))
		{
			sPath += "index.html";
		}
		else
		{
			sPath += "/index.html";
		}
	}
	return sPath;
}
function isThisUrl(sUrl)
{
	var sThis = getNavieUrl(window.location.href);
	var sUrl2 = getNavieUrl(sUrl);
	if (sThis == sUrl2)
	{
		return true;
	}
	return false;
}
/////////
function pushServerTime(sTime)
{
	var t = parseInt(sTime, 10);
	t = mkTime3("2010-06-10 11:29:55");
	g_cur_time = t;
	eval("g_cur_time = t;");
}
/////////////////////////////////////////////////